package czk.jvm.lecture.classloader;

/**
 * 初始化阶段是从上向下初始化
 * 先准备，再进行初始化
 * 所以代码顺序对初始化结果有影响
 */
public class MyTest6 {
    public static void main(String[] args) {
        Singleton singleton = Singleton.getInstance();
        System.out.println(singleton.i);
        System.out.println(singleton.j);
    }
}
class Singleton{
    public static int i=0;
    public static int j=2;
    private static Singleton singleton=new Singleton();
    public Singleton(){
        i++;
        j++;
    }

    public static Singleton getInstance(){
        return singleton;
    }
}
